package A_review.re2_17;

import java.util.HashSet;

public class Class202 {

    public boolean isHappy(int n) {
    HashSet<Integer> set = new HashSet<>();
    while (n!=1&&!set.contains(n)){
        set.add(n);
        n=getNext(n);
    }
     return  n==1;
    }


    public  int getNext(int n){
        int ans=0;
        while (n!=0){
            int m=n%10;
            ans+=m*m;
            n=n/10;
        }
        return ans;
    }




}
